#pragma once

namespace Tablebases
{

#define MAXPIECE 5

// data types used in end game database generator
#define int8      __int8
#define uint8     unsigned __int8
#define int16     __int16
#define uint16    unsigned __int16
//#define int32     __int32
#define uint32    unsigned __int32
#define int64     __int64
#define uint64    unsigned __int64



// declaration of bitboard position

struct BitBoard
{
	uint32 wm;
	uint32 bm;
	uint32 wk;
	uint32 bk;
	int score;
};

struct BitBoard64
{
	uint64 wm;
	uint64 bm;
	uint64 wk;
	uint64 bk;
	int score;
};

#define HiWord(x) (((x)&0xFFFF0000)>>16)
#define LoWord(x) ((x)&0xFFFF)
#define HiDWordHiWord(x) (((x)&0xFFFF000000000000)>>(16+32))
#define HiDWordLoWord(x) (((x)&0x0000FFFF00000000)>>32)


void InitBool();

// 32-bit routines
int LSB(uint32 x);
int MSB(uint32 x);
int RecBitCount(uint32 n);
int BitCount(uint32 n);
uint32 Revert(uint32 n);

// 64-bit routines
int LSB64(uint64 x);
int MSB64(uint64 x);
uint64 Revert64(uint64 n);
int BitCount64(uint64 n);

}

